// Interrupt service routines
#include "opt.h"
#include <htc.h>

void interrupt my_isr(void){

	/***** PortB Code *****/
	if((RBIE)&&(RBIF)){
		switch (statoInt){
				case 1:
					if(!IN1 || !IN2){
						if(!IN1){
							count = count - 1;
							statoInt=2;
		//					PrintNumber();
						}
						else{
							statoInt=4;
						}
					}
				break;
				case 2:
					if(IN1 && IN2){
						count = count + 1;
						statoInt =1;
					//	PrintNumber(count);
					}
					else
					if(!IN1 && !IN2)
						statoInt=3;
				break;
				case 3:
					if(IN1 && !IN2){
						statoInt =4;
					}
					else
					if(!IN1 && IN2)
						statoInt=2;
					break;
				case 4:
					if(!IN1 && !IN2)
						statoInt=3;
					else
					if(IN1 && IN2)
						statoInt=1;
					break;
				}
		
		RBIF=0;	// clear event flag
	}
	
}
